# from pydantic.generics import GenericModel
from pydantic import BaseModel
from typing import Generic, TypeVar, Optional

T = TypeVar("T")


# class Response(GenericModel, Generic[T]):
class Response(BaseModel, Generic[T]):  # pydantic.generics.GenericModel 类不再必要，已被移除。
    code: int = 0
    message: str = "OK"
    data: Optional[T] = None


"""
@router.get("/test", summary="测试", response_model=Response[str])
def test():
    return Response(data="测试成功")

@router.get("/test", summary="测试", response_model=Response[dict[str, str]])
def test():
    return Response(data={"message": "删除成功"})
    
@router.get("/user2/{user_id}", response_model=Response[UserOut])
async def get_user2(user_id: int):
    user = await User.get_or_none(id=user_id)
    if not user:
        raise BusinessException(code=4040, message="用户不存在")
    return Response(data=user)


@router.get("/users/", response_model=Response[list[UserOut]])
async def get_users():
    users = await User.all()
    return Response(data=users)  # 返回统一响应结构
"""
